package com.bnzj.core.web.security.handler;

import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;

/**
 * @ClassName UsernamePasswordAuthenticationParseFilter
 * @Description UsernamePasswordAuthenticationToken 解析
 * @Author
 * @Date 2020/3/3
 * @Version V1.0
 **/
public class UsernamePasswordAuthenticationParseFilter implements AuthenticationParseFilter {
    @Override
    public String getUserName(Authentication authentication) {
        if(authentication instanceof UsernamePasswordAuthenticationToken){
            return authentication.getPrincipal().toString();
        }
        return null;
    }
}
